import { ArrayMinSize, IsArray, IsNotEmpty, IsNumber, IsNumberString, IsOptional, IsString, Length, Max, MaxLength, Min } from "class-validator";
import { Device } from "src/entities/Device";
import PaginationDto from "src/dto/pagination.dto";

class Common extends Device{
    @IsNotEmpty()
    cate_1: number;

    @IsNotEmpty()
    cate_2: number;

    @MaxLength(30, {message : '设备名不能超过30个字符'})
    @IsString()
    @IsOptional()
    deviceName:string;

    @Max(30)
    @Min(1)
    @IsNumber()
    portCount:number;

    @Min(0)
    @IsNumber()
    @IsOptional()
    simId:number;

    
    @Min(0)
    @IsNumber()
    @IsOptional()
    provinceId:number;

    @Min(0)
    @IsNumber()
    @IsOptional()
    cityId:number;

    @Min(0)
    @IsNumber()
    @IsOptional()
    districtId:number;

    @MaxLength(50, {message : '地址不能超过50个字符'})
    @IsString()
    @IsOptional()
    address:string;

    @MaxLength(50, {message : '备注不能超过50个字符'})
    @IsString()
    @IsOptional()
    remark:string;
}

export class AddDto extends Common {
    
}

export class EditDto extends Common {

}



export default class ListDto extends PaginationDto{
    @IsString()
    @IsOptional()
    deviceName:string;

    @IsNumberString()
    @IsOptional()
    deviceId:number;

    @IsNumberString()
    @IsOptional()
    merchantId:number;

    @IsNumberString()
    @IsOptional()
    subMerchantId:number;

    @IsNumberString()
    @IsOptional()
    cate_1:number;

    @IsNumberString()
    @IsOptional()
    cate_2:number;

}


export class AllotMerchantDto {
    @Min(1)
    @IsNumber()
    merchantId:number;

    @ArrayMinSize(1, {message : '请选择设备'})
    @IsArray({message : '数据异常'})
    deviceIds:number[];
}

export class SetStrategyDto {
    @Min(1)
    @IsNumber()
    strategyId:number;

    @ArrayMinSize(1, {message : '请选择设备'})
    @IsArray({message : '数据异常'})
    deviceIds:number[];
}